package com.boil.qz.safekavass.weixin.model.receive;

/**
 * Created by ChenYong on 2017-04-28.
 * <br>
 * 接收消息基类（普通用户 -> 公众账号)。
 */
public class BaseMsg {
    /**
     * 开发者微信号
     */
    protected String ToUserName;
    /**
     * 发送方帐号（一个 OpenID）
     */
    protected String FromUserName;
    /**
     * 消息id，64位整型
     */
    protected Long MsgId;
    /**
     * 消息类型
     */
    protected String MsgType;
    /**
     * 消息创建时间 （整型）
     */
    protected Long CreateTime;

    /**
     * 无参构造器。
     */
    public BaseMsg() {
        super();
    }

    public String getToUserName() {
        return ToUserName;
    }

    public void setToUserName(String toUserName) {
        ToUserName = toUserName;
    }

    public String getFromUserName() {
        return FromUserName;
    }

    public void setFromUserName(String fromUserName) {
        FromUserName = fromUserName;
    }

    public Long getMsgId() {
        return MsgId;
    }

    public void setMsgId(Long msgId) {
        MsgId = msgId;
    }

    public String getMsgType() {
        return MsgType;
    }

    public void setMsgType(String msgType) {
        MsgType = msgType;
    }

    public Long getCreateTime() {
        return CreateTime;
    }

    public void setCreateTime(Long createTime) {
        CreateTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BaseMsg baseMsg = (BaseMsg) o;

        if (ToUserName != null ? !ToUserName.equals(baseMsg.ToUserName) : baseMsg.ToUserName != null) return false;
        if (FromUserName != null ? !FromUserName.equals(baseMsg.FromUserName) : baseMsg.FromUserName != null)
            return false;
        return MsgId != null ? MsgId.equals(baseMsg.MsgId) : baseMsg.MsgId == null;
    }

    @Override
    public int hashCode() {
        int result = ToUserName != null ? ToUserName.hashCode() : 0;
        result = 31 * result + (FromUserName != null ? FromUserName.hashCode() : 0);
        result = 31 * result + (MsgId != null ? MsgId.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("BaseMsg{");
        sb.append("ToUserName='").append(ToUserName).append('\'');
        sb.append(", FromUserName='").append(FromUserName).append('\'');
        sb.append(", MsgId=").append(MsgId);
        sb.append(", MsgType='").append(MsgType).append('\'');
        sb.append(", CreateTime=").append(CreateTime);
        sb.append('}');
        return sb.toString();
    }
}